enum LogType {
    success,
    error,
    info,
    warning,
}

type Logcof = {
    label: string;
    type?: keyof typeof LogType;
}

type CcLogFun = (data: any, logcof: Logcof) => void;

const color = {
    success: 'rgb(82, 196, 26)',
    error: 'rgb(255, 77, 79)',
    info: 'rgb(22, 119, 255)',
    warning: 'rgb(250, 173, 20)',
    default: 'rgba(0, 0, 0, 0.88)',
}

const backgroundColor = {
    success: 'rgb(246, 255, 237)',
    error: 'rgb(255, 242, 240)',
    info: 'rgb(230, 244, 255)',
    warning: 'rgb(255, 251, 230)',
    default: 'rgb(250, 250, 250)',
}

const borderColor = {
    success: 'rgb(183, 235, 143)',
    error: 'rgb(255, 204, 199)',
    info: ' rgb(145, 202, 255)',
    warning: 'rgb(255, 229, 143)',
    default: 'rgb(217, 217, 217)',
}

/** 
 * 日志打印
 */
const ccLog: CcLogFun = (data, config): void => {

    const {
        label,
        type = 'default',
    } = config || {};

    const style = `color: ${color[type]}; background-color: ${backgroundColor[type]}; padding: 6px; font-weight: bold; border-radius: 4px; border: 2px solid ${borderColor[type]};`

    console.log(`%cchaoyue_${label}`, style, data);
}

export default ccLog;